<script setup lang="ts">
import { computed, ref, watch } from 'vue';

const msg = 'Hello Vue 3 + TypeScript!'
let a1 = ''
let a2 = ''
console.log([a1, a2] = msg.split(' '))
console.log('a1:' + a1)
console.log('a2:' + a2)
const obj = [{ a: 1 }, { a: 2 }, { a: 3 }]
const sum = computed(() => {
  let tatal = obj.reduce((sum, index) => sum + index.a, 0)
  return tatal
})
console.log('sum：' + sum.value)
const 监听事件 = ref(20)
watch(监听事件, (newVal, oldVal) => {
  console.log('监听事件：' + newVal)
})
</script>
<template>
  <div>{{ sum }}</div>
  <div>{{ 监听事件 }}</div>
  <button @click="监听事件++">点击</button>
</template>